package com.example.module.ai.config;

import com.alibaba.cloud.ai.tongyi.chat.TongYiChatModel;
import com.example.module.ai.spark.util.SparkAiUtils;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
@EnableConfigurationProperties({SparkAiProperties.class, TencentAppProperties.class})
public class AiConfiguration {

    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        ServerEndpointExporter exporter = new ServerEndpointExporter();
        // 手动注册 WebSocket 端点，用了@Component就无需了
//        exporter.setAnnotatedEndpointClasses(EchoChannel.class);
        return exporter;
    }

    @Bean
    public SparkAiUtils sparkAiUtils(SparkAiProperties sparkAiProperties) {
        return new SparkAiUtils(sparkAiProperties);
    }

    @Bean
    public ChatClient tongYiClient(TongYiChatModel tongYiChatModel) {
        return ChatClient.create(tongYiChatModel);
    }

    @Bean
    public ChatClient deepseekChatClient(OllamaChatModel ollamaChatModel) {
        return ChatClient.create(ollamaChatModel);
    }
}
